from collections.abc import Generator
from logging import Logger
from typing import Any

from ducktape.cluster.cluster import Cluster
from ducktape.cluster.cluster_spec import ClusterSpec as ClusterSpec
from ducktape.command_line.defaults import ConsoleDefaults as ConsoleDefaults
from ducktape.mark.resource import (
    CLUSTER_SIZE_KEYWORD as CLUSTER_SIZE_KEYWORD,
)
from ducktape.mark.resource import (
    CLUSTER_SPEC_KEYWORD as CLUSTER_SPEC_KEYWORD,
)
from ducktape.services.service_registry import ServiceRegistry as ServiceRegistry
from ducktape.template import TemplateRenderer as TemplateRenderer
from ducktape.tests.loggermaker import (
    LoggerMaker as LoggerMaker,
)
from ducktape.tests.loggermaker import (
    close_logger as close_logger,
)
from ducktape.tests.status import FAIL as FAIL
from ducktape.tests.status import OFAIL as OFAIL
from ducktape.utils.local_filesystem_utils import mkdir_p as mkdir_p

class Test(TemplateRenderer):
    test_context: TestContext

    def __init__(
        self, test_context: TestContext, *args: Any, **kwargs: Any
    ) -> None: ...
    @property
    def cluster(self) -> Cluster: ...
    @property
    def logger(self) -> Logger: ...
    def min_cluster_spec(self) -> None: ...
    def min_cluster_size(self) -> None: ...
    def setup(self) -> None: ...
    def teardown(self) -> None: ...
    def setUp(self) -> None: ...
    def tearDown(self) -> None: ...
    def free_nodes(self) -> None: ...
    def compress_service_logs(
        self, node: Any, service: Any, node_logs: list[str]
    ) -> list[str]: ...
    def copy_service_logs(self, test_status: Any) -> None: ...
    def mark_for_collect(self, service: Any, log_name: str | None = ...) -> None: ...
    def mark_no_collect(self, service: Any, log_name: str | None = ...) -> None: ...
    def should_collect_log(self, log_name: str, service: Any) -> bool: ...

def test_logger(logger_name: str, log_dir: str, debug: bool) -> Logger: ...

class TestLoggerMaker(LoggerMaker):
    log_dir: str
    debug: bool

    def __init__(self, logger_name: str, log_dir: str, debug: bool) -> None: ...
    def configure_logger(self) -> None: ...

class TestContext:
    session_context: Any
    cluster: Cluster
    module: str
    test_suite_name: str
    file: str | None
    cls: Any
    function: Any
    injected_args: dict[str, Any] | None
    ignore: bool
    ok_to_fail: bool
    cluster_use_metadata: dict[str, Any]
    services: ServiceRegistry
    test_index: int | None
    log_collect: dict[tuple[str, Any], bool]

    def __init__(self, **kwargs: Any) -> None: ...
    def copy(self, **kwargs: Any) -> "TestContext": ...
    @property
    def local_scratch_dir(self) -> str: ...
    @property
    def test_metadata(self) -> dict[str, Any]: ...
    @staticmethod
    def logger_name(test_context: "TestContext", test_index: int | None) -> str: ...
    @staticmethod
    def results_dir(test_context: "TestContext", test_index: int | None) -> str: ...
    @property
    def expected_num_nodes(self) -> int: ...
    @property
    def expected_cluster_spec(self) -> Any: ...
    @property
    def globals(self) -> dict[str, Any]: ...
    @property
    def module_name(self) -> str: ...
    @property
    def cls_name(self) -> str: ...
    @property
    def function_name(self) -> str: ...
    @property
    def description(self) -> str: ...
    @property
    def injected_args_name(self) -> str: ...
    @property
    def test_id(self) -> str: ...
    @property
    def test_name(self) -> str: ...
    @property
    def logger(self) -> Logger: ...
    def close(self) -> None: ...

def in_dir(path: str) -> Generator[None, None, None]: ...
def in_temp_dir() -> Generator[str, None, None]: ...
